package com.zsyg.common.util;

import java.io.Serializable;

/**
 * @author: create by YangWanLi
 * @version: v1.0
 * @description: 接口返回数据格式化工具类
 * @date:2018/11/2
 */
public class JsonResultUtil implements Serializable {
	private static final long serialVersionUID = 1L;
	private int code = ConstantUtil.SUCESS_CODE;
	private String message = ConstantUtil.SUCESS_MESSAGE;
	private Object data;
	
	public JsonResultUtil() {}
	public JsonResultUtil(int code, String message) {
		this.code=code;
		this.message=message;
	}

	public JsonResultUtil(Object data) {
		this.data=data;
	}

	public JsonResultUtil(int code, String message, Object data) {
		this.code=code;
		this.message=message;
		this.data=data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public String toJson() {
		return JsonUtil.toJson(this);
	}
	
	@Override
	public String toString() {
		StringBuilder sb=new StringBuilder();
		sb.append("{").append(code).append(",").append(message).append("}");
		return sb.toString();
	}
}
